package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import java.awt.GridBagLayout;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JPanel jPanel2 = null;
	private EventTable eventTable = null;
	private FilterArea filterArea = null;
	private FilterCheckBox filterCheckBox = null;
	private JPanel jPanel3 = null;
	private JPanel jPanel1 = null;
	private DetailEditor detailEditor = null;
	private ConfigPanel configPanel = null;
	
	/**
	 * This is the default constructor
	 */
	public MainFrame() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(800, 600);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setContentPane(getJContentPane());
		this.setTitle("Organzier");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getJPanel2(), null);
			jContentPane.add(getJPanel1(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jLabel = new JLabel();
			jLabel.setText("Alle Ereignisse");
			jLabel.setFont(new Font("Dialog", Font.BOLD, 14));
			jLabel.setPreferredSize(new Dimension(38, 20));
			jPanel = new JPanel();
			jPanel.setLayout(new BorderLayout());
			jPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
			jPanel.setSize(new Dimension(500, 450));
			jPanel.setLocation(new Point(10, 10));
			jPanel.add(jLabel, BorderLayout.NORTH);
			jPanel.add(getJPanel3(), BorderLayout.CENTER);
		}
		return jPanel;
	}

	public void setEventTable(EventTable t) {
		this.eventTable = t;
		jPanel3.add(eventTable, BorderLayout.CENTER);
	}
	
	public void setFilterArea(FilterArea f) {
		this.filterArea = f;
		jPanel3.add(filterArea, BorderLayout.NORTH);
	}

	/**
	 * This method initializes jPanel2	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel2() {
		if (jPanel2 == null) {
			jPanel2 = new JPanel();
			jPanel2.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
			jPanel2.setLayout(new BorderLayout());
			jPanel2.setBounds(new Rectangle(10, 470, 500, 80));
		}
		return jPanel2;
	}
	
	public void setConfigPanel(ConfigPanel p){
		configPanel  = p;
		jPanel2.add(configPanel, BorderLayout.CENTER);
	}
	
	public void setDetailEditor(DetailEditor d) {
		detailEditor = d;
		jPanel1.add(detailEditor, BorderLayout.CENTER);
	}

	public void setFilterCheckBox(FilterCheckBox b) {
		this.filterCheckBox = b;
		jPanel3.add(filterCheckBox, BorderLayout.SOUTH);
	}
	
	/**
	 * This method initializes jPanel3	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			jPanel3 = new JPanel();
			jPanel3.setLayout(new BorderLayout());
		}
		return jPanel3;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.setLayout(new BorderLayout());
			jPanel1.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
			jPanel1.setSize(new Dimension(250, 250));
			jPanel1.setLocation(new Point(520, 301));
		}
		return jPanel1;
	}
}